package com._21cn.cms.site.service;

import com._21cn.cms.site.dao.ColumnCopyDao;
import com._21cn.cms.site.dao.ColumnDao;
import com._21cn.cms.site.entity.Column;
import com._21cn.cms.site.entity.ColumnCopy;
import com._21cn.framework.base.db.BaseDao;
import com._21cn.framework.base.service.impl.BaseServiceImpl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("columnCopyService")
public class ColumnCopyService extends BaseServiceImpl<ColumnCopy>
{

    @Autowired
    private ColumnCopyDao columnCopyDao;

    @Autowired
    private ColumnDao columnDao;

    protected BaseDao<ColumnCopy> getBaseDao()
    {
        return this.columnCopyDao;
    }

    public Column getSrcColumn(Integer destColumnId) {
        Map params = new HashMap();
        params.put("eqDestColumnId", destColumnId);
        params.put("eqStatus", Integer.valueOf(1));
        List list = this.columnCopyDao.selectByMap(params, 1, 1, false);
        Column column = new Column();
        if (list.size() > 0) {
            ColumnCopy columnCopy = (ColumnCopy)list.get(0);
            Integer srcColumnId = columnCopy.getSrcColumnId();
            column = (Column)this.columnDao.selectById(srcColumnId);
        }
        return column;
    }

    public Column getDestColumn(Integer srcColumnId) {
        Map params = new HashMap();
        params.put("eqSrcColumnId", srcColumnId);
        params.put("eqStatus", Integer.valueOf(1));
        List list = this.columnCopyDao.selectByMap(params, 1, 1, false);
        Column column = new Column();
        if (list.size() > 0) {
            ColumnCopy columnCopy = (ColumnCopy)list.get(0);
            Integer destColumnId = columnCopy.getDestColumnId();
            column = (Column)this.columnDao.selectById(destColumnId);
        }
        return column;
    }
}